package edu.hhu.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

import edu.hhu.model.Cjscjt;

public class BasicController extends Controller{
   public void index(){
	   String sql = "from cjscjt";
	   int pageNum = getParaToInt("pageName",1);
	   Page<Cjscjt> page = Cjscjt.dao.paginate(1, 20, "select *", sql);
	   this.setAttr("basic",page );
	   render("/basic/query.jsp");
   }
   public void page(){
	   String para = getPara(0);
	   String sql = "from cjscjt";
	   int pageNum=0;
	   System.out.println(para);
	   System.out.println();
	   if(para.equals("first")){
		   pageNum=getParaToInt(1);
		   System.out.println(pageNum);
	   }else if(para.equals("down")){
		   pageNum=getParaToInt(1)+1;
		   System.out.println(pageNum);
	   }else if(para.equals("up")){
		   pageNum=getParaToInt(1)-1;
		   System.out.println(pageNum);
	   }else if(para.equals("last")){
		   pageNum=getParaToInt(1);
		   System.out.println(pageNum);
	   }
	   Page<Cjscjt> page = Cjscjt.dao.paginate(pageNum, 20, "select *", sql);
	   this.setAttr("basic",page );
	   render("/basic/query.jsp");
   }
   
}
